//
//  UILabel+LbCategory.m
//  Stars
//
//  Created by 魏鹏 on 2017/7/3.
//  Copyright © 2017年 hst. All rights reserved.
//

#import "UILabel+LbCategory.h"

@implementation UILabel (LbCategory)

+(UILabel *)initLableWithTextColor:(UIColor *)textColor withTextFont:(UIFont *)font withTextAlignment:(NSTextAlignment)alignment withBackGroundColor:(UIColor *)backGroundColor{
    
    UILabel * lb = [UILabel new];
    lb.textColor = textColor?:[UIColor blackColor];
    lb.font = font?:[UIFont systemFontOfSize:14.0f];
    lb.textAlignment = alignment?:NSTextAlignmentLeft;
    lb.backgroundColor = backGroundColor?:[UIColor whiteColor];
    
    return lb;
}



- (void)settingLabelRowOfHeight:(CGFloat)height string:(NSString*)string{
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:height]; //调整行间距
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [string length])];
    self.attributedText = attributedString;
    [self sizeToFit];
}



@end
